package clickhouse

import "fmt"

type Conf struct {
	Host         string
	Port         int
	User         string
	Password     string
	DBName       string
	TablePrefix  string `json:",optional"`
	Debug        bool
	Parameters   string `json:",optional"`
	MaxLifetime  int    `json:",optional"`
	MaxOpenConns int    `json:",optional"`
	MaxIdleConns int    `json:",optional"`

	ReadTimeout  int
	WriteTimeout int
}

func (m Conf) DSN() string {
	return fmt.Sprintf("tcp://%s:%d?username=%s&password=%s&database=%s&read_timeout=%d&write_timeout=%d",
		m.Host, m.Port, m.User, m.Password, m.DBName, m.ReadTimeout, m.WriteTimeout)
}
